import { getAllCountryApi } from "@/api/configCenter/countryRegion";
import { reactive, ref } from "vue";

export default function InitHook() {
  const formState = reactive<Partial<ClientAddressManagement.AddNoFbaAddressForm>>({
    countryRegionManageId: undefined,
    city: undefined,
    state: undefined,
    postcode: undefined,
    address: undefined,
    contact: undefined,
    phone: undefined,
    email: undefined,
    companyName: undefined
  });
  const loading = ref<boolean>(false);
  const formDataRef = ref<any>(null);
  const countryOpts = ref<Array<Base.GeneraDataType>>([]);
  const getCountryOpts = () => {
    return getAllCountryApi(1).then((res: any) => {
      const { code, data } = res;
      if (code === 200) {
        countryOpts.value = data;
      }
    });
  };
  return {
    formState,
    formDataRef,
    loading,
    getCountryOpts,
    countryOpts
  };
}
